<div class="row">
<?php
/* @var $this MstClientController */
/* @var $model MstClient */
?>
<?php

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
");
?>
<?php
$this->breadcrumbs=array(
	'Mst Clients'=>array('index'),
	$model->name,
);
?>

<h1>Client #<?php echo $model->client_number; ?></h1>
<div class="col-md-6">
<?php $this->widget('zii.widgets.CDetailView',array(
    'htmlOptions' => array(
        'class' => 'table table-striped table-condensed table-hover',
    ),
    'data'=>$model,
    'attributes'=>array(
		'client_number',
		'name',
		'address',
		array(
			'name'=>'city_id',
			'value'=>MstTypeContent::model()->findByPk($model->city_id)->name,
		),
		array(
			'name'=>'province_id',
			'value'=>MstTypeContent::model()->findByPk($model->province_id)->name,
		),
		'zip',
		'phone',
		'mobile',
		'fax',
	),
)); ?>
</div>

<h2 class="grs">QQ</h2><br />
<a href="<?php echo Yii::app()->createUrl('mstClientPersons/import/cli/'.$model->id); ?>" class="btn btn-sm btn-primary">Add Persons</a>&nbsp;&nbsp;&nbsp;
<a href="<?php echo Yii::app()->createUrl('mstClient/createqq/parent/'.$model->id); ?>" class="btn btn-sm btn-primary">Add QQ</a><br /><br />
<?php echo CHtml::link('View Person','#',array('class'=>'search-button btn')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('viewPerson',array(
	'id'=>$model->id,
)); ?>
</div><!-- search-form -->
<br />
<br />
<br />

<?php
//$treeManager     = treeManager::get();Yii::app()->sendMail->MailerConfirmation()
$records         = Yii::app()->db->createCommand()
					->select('id, parent_id,name,client_number')
					->from('mst_client')
					->where('groups='.$model->groups)
					->queryAll();
// here we have our multidimensional, weightsorted tree!
$recordsTree     = Yii::app()->getTrees->getTree( $records );


Yii::app()->getTrees->olLiTree($recordsTree);

/*
WITH    RECURSIVE q AS
        (
        SELECT  m.id,m.name,m.parent_id
        FROM    mst_client m
        WHERE   id = 8
        UNION ALL
        SELECT  m.id,m.name,m.parent_id
        FROM    q
        JOIN    mst_client m
        ON      m.id = q.parent_id
        )
SELECT  *
FROM    q
WHERE   q.parent_id=0
*/
?>










</div>
